package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.entity.resource.LogApi;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BasePageResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseSelectResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.station.*;
import com.zmj.sy.mom.srv.aps.service.StationService;
import com.zmj.sy.mom.srv.aps.utils.JsonUtils;
import com.zmj.sy.mom.srv.aps.utils.SyExceptionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequiredArgsConstructor
@Api(tags = "工位")
@RestController
@RequestMapping("/station")
public class StationController {

    private final StationService stationService;

    @ApiOperation("1.6.1 添加工位")
    @PostMapping("/add")
    public BaseResVo add(@RequestBody StationAddReqVo reqVo){
        stationService.add(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.6.2 工位列表")
    @GetMapping("/list")
    public BasePageResVo<StationListResVo> list(StationListReqVo reqVo){
        return stationService.list(reqVo);
    }
    @ApiOperation("1.6.3 根据ID获取工位")
    @GetMapping("/get")
    public StationGetResVo get(BaseIdReqVo reqVo){
        return stationService.get(reqVo);
    }

    @ApiOperation("1.6.4 修改工位")
    @PostMapping("/edit")
    public BaseResVo edit(@RequestBody StationEditReqVo reqVo){
        stationService.edit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.6.5 删除工位")
    @PostMapping("/delete")
    public BaseResVo delete(BaseIdReqVo reqVo){
        stationService.delete(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.6.6 查看工位工作能力")
    @GetMapping("/getMachine")
    public StationGetMachineResVo getMachine(BaseIdReqVo reqVo){
        return stationService.getMachine(reqVo);
    }

    @ApiOperation("1.6.7 设置工位工作能力")
    @PostMapping("/editMachine")
    public BaseResVo editMachine(@RequestBody StationEditMachineReqVo reqVo){
        stationService.editMachine(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.6.8 查看规则")
    @GetMapping("/getRule")
    public StationGetRuleResVo getRule(BaseIdReqVo reqVo){
        return stationService.getRule(reqVo);
    }
    @ApiOperation("1.6.9 设置规则")
    @PostMapping("/editRule")
    public BaseResVo editRule(@RequestBody StationEditRuleReqVo reqVo){
        stationService.editRule(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.6.10 查看所有的工位")
    @GetMapping("/select")
    public BaseSelectResVo select(BaseIdReqVo reqVo){
        return stationService.select(reqVo);
    }

    @ApiOperation("零件进入")
    @PostMapping("/partIn")
    public BaseResVo partIn(StationPartInReqVo reqVo) {
        stationService.partIn(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("零件离开")
    @PostMapping("/partOut")
    public BaseResVo partOut(StationPartOutReqVo reqVo) {
        stationService.partOut(reqVo);
        return BaseResVo.ok();
    }



}
